import Vue from "vue";
import VueRouter from "vue-router";
import MainLayout from "@/views/layout/MainLayout";
import IndexLayout from "@/views/layout/IndexLayout";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    component: MainLayout,
    redirect: "/home",
    children: [
      {
        path: "/home",
        name: "home",
        component: () =>
          import(/* webpackChunkName: "home" */ "../views/home/Home.vue")
      },
      {
        path: "/order",
        name: "order",
        component: () =>
          import(/* webpackChunkName: "order" */ "../views/order/Order.vue")
      },
      {
        path: "/record",
        name: "record",
        component: () =>
          import(/* webpackChunkName: "record" */ "../views/record/Record.vue")
      },
      {
        path: "/kefu",
        name: "kefu",
        component: () =>
          import(/* webpackChunkName: "kefu" */ "../views/kefu/Kefu.vue")
      },
      {
        path: "/my",
        name: "my",
        component: () =>
          import(/* webpackChunkName: "my" */ "../views/my/My.vue")
      }
    ]
  },
  {
    path: "/",
    component: IndexLayout,
    children: [
      {
        path: "/login",
        name: "login",
        component: () =>
          import(/* webpackChunkName: "login" */ "../views/login/Login.vue")
      },
      {
        path: "/register",
        name: "register",
        component: () =>
          import(
            /* webpackChunkName: "register" */ "../views/login/Register.vue"
          )
      },
      {
        path: "/forget",
        name: "forget",
        component: () =>
          import(/* webpackChunkName: "forget" */ "../views/login/Forget.vue")
      },
      {
        path: "/order/:id",
        name: "orderDetail",
        component: () =>
          import(
            /* webpackChunkName: "orderDetail" */ "../views/order/OrderDetail.vue"
          )
      },
      {
        path: "/kefu/online",
        name: "online",
        component: () =>
          import(/* webpackChunkName: "online" */ "../views/kefu/Online.vue")
      },
      {
        path: "/fund",
        name: "fund",
        component: () =>
          import(
            /* webpackChunkName: "fund" */ "../views/my/components/Fund.vue"
          )
      },
      {
        path: "/withdraw",
        name: "withdraw",
        component: () =>
          import(
            /* webpackChunkName: "withdraw" */ "../views/withdraw/index.vue"
          )
      },
      {
        path: "/withdraw/choose",
        name: "withdrawChoose",
        component: () =>
          import(
            /* webpackChunkName: "withdrawChoose" */ "../views/withdraw/components/ChooseCard.vue"
          )
      },
      {
        path: "/withdraw/add",
        name: "withdrawAdd",
        component: () =>
          import(
            /* webpackChunkName: "withdrawAdd" */ "../views/withdraw/components/AddCard.vue"
          )
      },
      {
        path: "/card/remove",
        name: "cardRemove",
        component: () =>
          import(
            /* webpackChunkName: "cardRemove" */ "../components/card/RemoveCard.vue"
          )
      },
      {
        path: "/card/all",
        name: "cardAll",
        component: () =>
          import(
            /* webpackChunkName: "cardAll" */ "../components/card/AllCard.vue"
          )
      },
      {
        path: "/recharge",
        name: "recharge",
        component: () =>
          import(
            /* webpackChunkName: "recharge" */ "../views/recharge/Recharge.vue"
          )
      },
      {
        path: "/offline",
        name: "offline",
        component: () =>
          import(
            /* webpackChunkName: "offline" */ "../views/offline/Offline.vue"
          )
      },
      {
        path: "/record",
        name: "record",
        component: () =>
          import(
            /* webpackChunkName: "record" */ "../views/my/components/Record.vue"
          )
      },
      {
        path: "/share",
        name: "share",
        component: () =>
          import(
            /* webpackChunkName: "share" */ "../views/my/components/Share.vue"
          )
      },
      {
        path: "/about",
        name: "about",
        component: () =>
          import(
            /* webpackChunkName: "about" */ "../views/my/components/About.vue"
          )
      },
      {
        path: "/down",
        name: "down",
        component: () =>
          import(
            /* webpackChunkName: "down" */ "../views/my/components/Down.vue"
          )
      },
      {
        path: "/setting",
        name: "setting",
        component: () =>
          import(
            /* webpackChunkName: "setting" */ "../views/setting/Setting.vue"
          )
      },
      {
        path: "/address",
        name: "address",
        component: () =>
          import(
            /* webpackChunkName: "address" */ "../views/setting/components/Address.vue"
          )
      },
      {
        path: "/lixibao",
        name: "lixibao",
        component: () =>
          import(
            /* webpackChunkName: "lixibao" */ "../views/finances/Lixibao.vue"
          )
      },
      {
        path: "/finances",
        name: "finances",
        component: () =>
          import(
            /* webpackChunkName: "finances" */ "../views/finances/Finances.vue"
          )
      },
      {
        path: "/404",
        name: "error",
        component: () =>
          import(/* webpackChunkName: "error" */ "@/views/error/404.vue")
      }
    ]
  },
  {
    path: "*",
    redirect: "/404"
  }
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

export default router;
